package com.LachesismStorm.lachesism.member.controller;

import com.LachesismStorm.lachesism.core.common.response.ResponsePage;
import com.LachesismStorm.lachesism.core.common.response.ResponseResult;
import com.LachesismStorm.lachesism.member.service.LachesismService;
import com.LachesismStorm.lachesism.member.vo.OssFile;
import io.swagger.annotations.Api;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author lachesism
 * @Date 2025-02-14 02:58
 **/
@RestController
@Api(tags = "lachesism2")
@RequestMapping("/lachesism2")
public class LachesismController {

    @Resource
    private LachesismService lachesismService;

    @PostMapping("/getRandomUrl")
    public ResponseResult getRandomUrl() {
        List<String> urlList = lachesismService.getRandomUrl();
        return ResponseResult.success(urlList);
    }

    @PostMapping("/getOssFileList")
    public ResponseResult getOssFileList(@RequestBody OssFile file) {
        ResponsePage<OssFile> fileList = lachesismService.getOssFileList(file);
        return ResponseResult.success(fileList);
    }

    @PostMapping("/getDownLoadUrl")
    public ResponseResult getDownLoadUrl(@RequestParam Integer id) {
        String url = lachesismService.getDownLoadUrl(id);
        return ResponseResult.success(url);
    }

    @PostMapping("/uploadOssFile")
    public ResponseResult uploadOssFile(@RequestBody OssFile fileInfo) {
        lachesismService.uploadOssFile(fileInfo);
        return ResponseResult.success(null, "上传成功");
    }
}
